Neurosis Engine
model.h
Go to the documentation of this file.
00001 
00002 // Neurosis Engine - LP23.com
00003 // Copyright © Luigi Pino. All rights reserved.
00004 
00005 /***************************************************************************/
00006 
00007 #ifndef _NEUROSIS_ENGINE_MODEL_H_
00008 #define _NEUROSIS_ENGINE_MODEL_H_
00009 
00010 /***************************************************************************/
00011 
00012 struct SRenderBatch {
00013   float mTextureX, mTextureY;
00014   float mColorR, mColorG, mColorB, mColorA;
00015   float mNormalX, mNormalY, mNormalZ;
00016   float mVertexX, mVertexY, mVertexZ;
00017 };
00018 
00019 /***************************************************************************/
00020 
00021 class CNeurosisPoints {
00022   public:
00023     CNeurosisPoints();
00025     ~CNeurosisPoints();
00026 
00027     void  operator= (CNeurosisPoints &rhs);
00028     bool  operator== (CNeurosisPoints rhs);
00030     bool  operator!= (CNeurosisPoints rhs);
00031 
00033     void  Initialize();
00034 
00035     color3  mColor;
00036     float3  mPosition;
00037 };
00038 
00039 /***************************************************************************/
00040 
00041 class CNeurosisTriangles {
00042   public:
00043     CNeurosisTriangles();
00045     ~CNeurosisTriangles();
00046 
00047     void  operator= (CNeurosisTriangles &rhs);
00048     bool  operator== (CNeurosisTriangles rhs);
00050     bool  operator!= (CNeurosisTriangles rhs);
00051 
00053     void  Initialize();
00054 
00055     float   mTransparency;                            // Transparency [0.0f..1.0f]
00056     float3  mCenter;                                  // Center
00057     float3  mNormal;                                  // Normal
00058     float3  mSideNormals[3];                          // Normal of corresponding sides
00059     float3  mPercent[3];                              // Texture coordinates
00060     int     iMesh;                                    // Mesh index
00061     int     iTexture;                                 // Texture index
00062     int     mPoint[3];                                // CNeurosisPoints index reference
00063 };
00064 
00065 /***************************************************************************/
00066 
00067 class CNeurosisModel {
00068   public:
00069     CNeurosisModel();
00071     ~CNeurosisModel();
00072 
00074     void  operator= (CNeurosisModel &rhs);
00075 
00077     int     Add_Point(float3 *newPoint, bool duplicateCheck = true);
00079     int     Add_Triangle(int point0, int point1, int point2);
00081     void    Add_Triangle(int iTexture, float bottomLeftX, float bottomLeftY, float bottomLeftZ, float topRightX, float topRightY, float topRightZ, float topLeftX, float topLeftY, float topLeftZ, float bottomLeftPercentX = 0.0f, float bottomLeftPercentY = 0.0f, float topRightPercentX = 1.0f, float topRightPercentY = 1.0f, float topLeftPercentX = 0.0f, float topLeftPercentY = 1.0f);
00083     void    Add_Quad(int iTexture, float bottomLeftX, float bottomLeftY, float bottomLeftZ, float bottomRightX, float bottomRightY, float bottomRightZ, float topRightX, float topRightY, float topRightZ, float topLeftX, float topLeftY, float topLeftZ, float bottomLeftPercentX = 0.0f, float bottomLeftPercentY = 0.0f, float bottomRightPercentX = 1.0f, float bottomRightPercentY = 0.0f, float topRightPercentX = 1.0f, float topRightPercentY = 1.0f, float topLeftPercentX = 0.0f, float topLeftPercentY = 1.0f);
00085     void    Calculate_Centers();
00087     void    Calculate_Normals();
00089     void    Calculate_Radius();
00091     bool    File_Load(char *filename);
00093     bool    File_Save(char *filename);
00095     float   Get_Mass();
00097     int     Get_Total_Triangles();
00099     int     Get_Total_Points();
00101     float   Get_Transparency(int iTriangle);
00103     void    Move(float3 *amount, bool modifyPoints = true);
00105     bool    Oct_Tree(int iTriangle, CNeurosisModel *destModel, float3 *highBound, float3 *lowBound);
00107     float   Plane_Distance(int iTriangle, int iNormal, float3 *point);
00109     int     Plane_Orientation(int iTriangle, int iNormal, float3 *point);
00111     float3  Polygon_Get_Position(int iTriangle, int iPoint);
00113     int     Polygon_Orientation(int iTriangle, float3 *point);
00115     int     Remove_Point(int index);
00117     int     Remove_Triangle(int index);
00119     void    Render(int iTriangle = -1, int iMesh = -1, bool isTextured = true);
00121     int     Render_Batch(int iArray, SRenderBatch batch[], int iMesh = -1);
00123     void    Resize_Points(int newSize);
00125     void    Resize_Triangles(int newSize);
00127     void    Rotate_x(float amount);
00129     void    Rotate_y(float amount);
00131     void    Rotate_z(float amount);
00133     void    Set_Mass(float amount);
00135     void    Set_Transparency(float amount, int iTriangle = -1);
00136 
00137     CNeurosisPoints     *pPoints;                     // Point memory
00138     CNeurosisTriangles  *pTriangles;                  // Triangle memory
00139 
00140     float               mRadius;                      // Radius
00141     float3              mBase;                        // Base point
00142     float3              mCurrent;                     // Current position
00143     float3              mPrevious;                    // Previous position
00144     float3              mVector;                      // Movement vector
00145 
00146   private:
00147     float               mMass;                        // Mass [min 0.0f]
00148     int                 mTotalPoints;                 // Total points
00149     int                 mTotalTriangles;              // Total triangles
00150 };
00151 
00152 /***************************************************************************/
00153 #endif